/*
 * @Description: 批次管理类型导航
 * @Author: Rfan
 * @Date: 2022-05-03 17:30:40
 * @LastEditTime: 2022-05-09 11:16:36
 */

import { Menu } from 'antd';
import cs from 'classnames';
import { useAccessionMgtContext } from '../contexts/AccessionMgtContext';
import type { MenuInfo } from 'rc-menu/lib/interface';

const PageSidebar = (props: any) => {
  const { className } = props;
  const { selectReceiveType, receiveTypeList, setSelectReceiveType } = useAccessionMgtContext();

  const items = receiveTypeList.map((item: any) => ({ label: item.name, key: item.id }));

  /**
   * @description: 切换导出类型
   * @param {MenuInfo} param 点击条目信息
   */
  const changeNav = ({ key }: MenuInfo) => {
    setSelectReceiveType(parseInt(key, 10));
  };

  return (
    <>
      <Menu
        className={cs('batch-sidebar', className)}
        items={items}
        selectedKeys={[`${selectReceiveType}`]}
        onClick={changeNav}
      />
    </>
  );
};

export default PageSidebar;
